<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>cors</title>
</head>
<body>
<script>
    let xhr = new XMLHttpRequest;
    xhr.open('GET', 'http://localhost:4000/getData', true);
    xhr.setRequestHeader("name", "fql");
    document.cookie="name=fql";//cookie是不允许跨域等
    xhr.withCredentials=true;//必须携带凭证
    xhr.onreadystatechange = function () {
        if (xhr.status >= 200 && xhr.status < 300 ||
            xhr.status === 304) {
            console.log(xhr.response)
            console.log(xhr.getResponseHeader('name'))
        }
    }
    xhr.send();
</script>

</body>
</html>